# Maintainer : Daniel Bermond <dbermond@archlinux.org>
# Contributor: drakkan <nicola.murino at gmail dot com>

pkgname=openh264
pkgver=2.3.1
pkgrel=1
_gtestver=1.8.1
pkgdesc='H.264 encoder and decoder'
arch=('loong64' 'x86_64')
url='https://www.openh264.org/'
license=('BSD')
depends=('gcc-libs')
makedepends=('nasm')
provides=('libopenh264.so')
source=("https://github.com/cisco/openh264/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz"
        "https://github.com/google/googletest/archive/release-${_gtestver}/googletest-${_gtestver}.tar.gz")
sha256sums=('453afa66dacb560bc5fd0468aabee90c483741571bca820a39a1c07f0362dc32'
            '9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c')

prepare() {
    ln -sf "../googletest-release-${_gtestver}" "${pkgname}-${pkgver}/gtest"
}

build() {
    make -C "${pkgname}-${pkgver}"
}

check() {
    make -C "${pkgname}-${pkgver}" test
    cd "${pkgname}-${pkgver}/testbin"
    ./CmdLineExample.sh
}

package() {
    make -C "${pkgname}-${pkgver}" DESTDIR="$pkgdir" PREFIX='/usr' install
    install -D -m755 "${pkgname}-${pkgver}"/h264{dec,enc} -t "${pkgdir}/usr/bin"
    install -D -m644 "${pkgname}-${pkgver}/LICENSE" -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
